import pandas as pd
from functools import reduce
ds = []
data_1 = pd.read_csv('./dataset/train/inputs/CO含量.csv').drop_duplicates(subset=['时间'],keep='last')
data_2 = pd.read_csv('./dataset/train/inputs/HCL含量.csv').drop_duplicates(subset=['时间'],keep='last')
data_3 = pd.read_csv('./dataset/train/inputs/NOx含量.csv').drop_duplicates(subset=['时间'],keep='last')
data_4 = pd.read_csv('./dataset/train/inputs/SO2含量.csv').drop_duplicates(subset=['时间'],keep='last')
data_5 = pd.read_csv('./dataset/train/inputs/一次风调门.csv').drop_duplicates(subset=['时间'],keep='last')
data_6 = pd.read_csv('./dataset/train/inputs/一次风量.csv').drop_duplicates(subset=['时间'],keep='last')
data_7 = pd.read_csv('./dataset/train/inputs/主蒸汽流量设定值.csv').drop_duplicates(subset=['时间'],keep='last')
data_8 = pd.read_csv('./dataset/train/inputs/二次风调门.csv').drop_duplicates(subset=['时间'],keep='last')
data_9 = pd.read_csv('./dataset/train/inputs/二次风量.csv').drop_duplicates(subset=['时间'],keep='last')
data_10 = pd.read_csv('./dataset/train/inputs/引风机转速.csv').drop_duplicates(subset=['时间'],keep='last')
data_11 = pd.read_csv('./dataset/train/inputs/推料器启停.csv').drop_duplicates(subset=['时间'],keep='last')
data_12 = pd.read_csv('./dataset/train/inputs/推料器手动指令.csv').drop_duplicates(subset=['时间'],keep='last')
data_13 = pd.read_csv('./dataset/train/inputs/推料器自动指令.csv').drop_duplicates(subset=['时间'],keep='last')
data_14 = pd.read_csv('./dataset/train/inputs/推料器自动投退信号.csv').drop_duplicates(subset=['时间'],keep='last')
data_15 = pd.read_csv('./dataset/train/inputs/氧量设定值.csv').drop_duplicates(subset=['时间'],keep='last')
data_16 = pd.read_csv('./dataset/train/inputs/汽包水位.csv').drop_duplicates(subset=['时间'],keep='last')
data_17 = pd.read_csv('./dataset/train/inputs/炉排启停.csv').drop_duplicates(subset=['时间'],keep='last')
data_18 = pd.read_csv('./dataset/train/inputs/炉排手动指令.csv').drop_duplicates(subset=['时间'],keep='last')
data_19 = pd.read_csv('./dataset/train/inputs/炉排实际运行指令.csv').drop_duplicates(subset=['时间'],keep='last')
data_20 = pd.read_csv('./dataset/train/inputs/炉排自动投退信号.csv').drop_duplicates(subset=['时间'],keep='last')
data_21 = pd.read_csv('./dataset/train/inputs/给水流量.csv').drop_duplicates(subset=['时间'],keep='last')
ds.append(data_1)
ds.append(data_2)
ds.append(data_3)
ds.append(data_4)
ds.append(data_5)
ds.append(data_6)
ds.append(data_7)
ds.append(data_8)
ds.append(data_9)
ds.append(data_10)
ds.append(data_11)
ds.append(data_12)
ds.append(data_13)
ds.append(data_14)
ds.append(data_15)
ds.append(data_16)
ds.append(data_17)
ds.append(data_18)
ds.append(data_19)
ds.append(data_20)
ds.append(data_21)

ret = reduce(lambda left,right: pd.merge(left,right,on='时间',how='outer'), ds)
ret = ret.fillna(value=True)
ret['推料器自动投退信号'] = ret['推料器自动投退信号'].astype('int')
ret['炉排启停'] = ret['炉排启停'].astype('int')
ret['炉排自动投退信号'] = ret['炉排自动投退信号'].astype('int')
ret['推料器启停'] = ret['推料器启停'].astype('int')
ret.to_csv('./data_jsee.csv')


y = pd.read_csv('./dataset/train/outputs/主蒸汽流量.csv').drop_duplicates(subset=['时间'],keep='last').pop('主蒸汽流量')
y.to_csv('./target.csv')

